#!/bin/sh
#(c) copyright Barry Kauler 2008, puppylinux.com
#2008 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
#This is the first startup script for UniPup, which runs entirely in initramfs.
#The 'createpuppy_unipup' script in Unleashed renames this from 'rc.sysinit-UNIPUP' to
#'rc.sysinit' (replacing any older rc.sysinit in the Unleashed build environment).
#Note, UniPup does not have an 'init' script (/init is a symlink to /bin/busybox).
#Note, do not edit this script. It reloads from initrd.gz at bootup.
#v404 first release. written from scratch, aiming for simplicity and speed.
#v405 alsa fix.
#v406 load apm.ko if no acpi.
#v409 gparted create ext3 part. failed, fixed by making /etc/mtab a symlink.
#v411 added minix|ext4|xfs support.
#v411 changed default to aufs, implement pfix values nox, nosave, nosfs
#v411 fix mouse detection logic.
#v411 can use old network wizard (from 403, based on 400)
#v411 return of 'puppyserialdetect', for usb/ps2 mouse detection only. now 'puppyinputdetect'.
#v411 extra 'sleep 1' as rerwin reports usb mouse may need it some hardware.
#v411 choosemousefunc().
#v412 /etc/DISTRO_SPECS, renamed pup_xxx.sfs, pup_save.2fs etc.
#v555 pup files renamed to woofr555.sfs, woofsave.tar.gz, woofu555.sfs.
#100126 move syslogd, klogd to /etc/init.d/00sys_logger
#100131 bugfix detect multiple cd/dvd drives.

. /etc/rc.d/functions4puppy4
. /etc/DISTRO_SPECS

status_func() {
 if [ $1 -eq 0 ];then
  /bin/echo -e "\\033[72G\\033[1;32mdone\\033[0;39m" >/dev/console #green [done] msg.
 else
  /bin/echo -e "\\033[70G\\033[1;31mfailed\\033[0;39m" >/dev/console #red [failed].
  STATUS=0
 fi
}

. /etc/rc.d/MODULESCONFIG #modules loading configuration.
#PUPPYVERSION=`cat /etc/puppyversion`
PATH=/bin:/sbin
[ $layerfs ] && LAYERFS=$layerfs #boot param.
[ ! $LAYERFS ] && LAYERFS=aufs #aufs or unionfs v411
[ $loglevel ] && LOGLEVEL=$loglevel #boot param.
[ $pmedia ] && PMEDIA=$pmedia #boot parameter, broad category of boot media. ex: cd.
[ $pdev1 ] && PDEV1=$pdev1    #boot parameter, partition have booted off. ex: hda3
STATUS=0

#v411...
if [ "$pfix" ];then
 for ONEFIX in `echo -n "$pfix" | tr ',' ' '`
 do
  case $ONEFIX in
   nox)     PNOX="yes";;          #do not start X.
   nosave)  PNOSAVE="yes";;       #do not load any ${DISTRO_FILE_PREFIX}save file.
   nosfs)   PNOSFS="yes";;        #do not load any sfs files at all.
  esac
 done
fi

##############MAKE FILESYSTEM USABLE################
echo -n "Making the 'RAM filesystem' usable..." >/dev/console #need this redirection!
busybox mount -t proc none /proc ;STATUS=$((STATUS+$?))
busybox mount -t sysfs none /sys ;STATUS=$((STATUS+$?))
busybox mount -t rootfs -o remount,rw rootfs / ;STATUS=$((STATUS+$?))
busybox mount /dev/pts ;STATUS=$((STATUS+$?))

#ln -s /proc/mounts /etc/mtab #resize2fs,e2fsck need this.
#...um, no, as my /bin/mount,umount scripts generate /etc/mtab.
#v409 mount/umount scripts no longer write to /etc/mtab, as gparted failed to create a
#ext3 partition -- dunno why. Instead, now have /etc/mtab a symlink to /proc/mounts...
rm -f /etc/mtab
ln -s /proc/mounts /etc/mtab

#redirect all output to a log file (must do after remount rw)...
[ ! "$LOGLEVEL" ] && exec 1>/tmp/bootsysinit.log 2>&1

status_func $STATUS

#################LOAD KERNEL MODULES################
echo -n "Loading kernel modules..." >/dev/console

#ha ha, this is putting the cart before the horse!...
#(will need to save /etc/MODULESCONFIG into the initrd.gz file at shutdown, if modified)
#setup blacklist... (SKIPLIST is in /etc/MODULESCONFIG)
BLACKLISTVARS="`echo "$SKIPLIST" | tr '\-' '_' | tr ' ' '\n' | sed -e 's/^/blacklist /' | grep -v ' $'`"
echo "$BLACKLISTVARS" > /tmp/pup_event_modprobe.conf #read in /sbin/pup_event_backend_d

#v405 udevd calls /sbin/pup_event_backend_modprobe, which needs this...
echo -n '0' > /tmp/pup_event_alsa_cnt

#my intention is for puppy to work with either of these...
if [ -f /sbin/udevd ];then
 /sbin/udevd --daemon
else
 pup_event_backend_d >/tmp/pup_event_backend_errors 2>&1 & #hotplug daemon. my homebrew replacement for udevd.
fi
sleep 0.1

#replay uevents from /sys...
MODALIASES="`ls /sys/bus/*/devices/*/modalias`"
for ONEMODALIAS in $MODALIASES
do
 ONEPATH="`dirname $ONEMODALIAS`"
 if [ -e ${ONEPATH}/uevent ];then
  echo add > ${ONEPATH}/uevent #generates an 'add' uevent.
  sleep 0.02
 fi
done
#do something to fill small time-slot... rc.shutdown uses this info...
#this is an exclusion list, files that will not be saved to user's ${DISTRO_FILE_PREFIX}save...
find /bin -mount -type f > /tmp/init_startup_files
find /sbin -mount -type f >> /tmp/init_startup_files
find /etc -mount -type f >> /tmp/init_startup_files
find /root -mount -type f >> /tmp/init_startup_files
find /opt -mount -type f >> /tmp/init_startup_files
find /lib -mount -type f >> /tmp/init_startup_files
#driver now builtin to libata pata kernel... do this for old kernel...
if [ -e /proc/ide ];then
 #ide zip or ide ls-120 drive?...
 [ ! "`dmesg | grep "ATAPI FLOPPY"`" = "" ] && modprobe ide-floppy
fi

modprobe nls_cp437 #these needed by vfat/ntfs/ext2 f.s.'s.
modprobe nls_iso8859-1 # "
modprobe fuse
modprobe $LAYERFS #unionfs or aufs.
modprobe squashfs

#we can determine ide/sata drives at this point (drivers builtin to kernel)...
#old kernel, no pata, have /proc/ide, these will be sata only...
#ATADRIVES="`ls -1 /sys/block | grep '^sd' | tr '\n' ' '`"
ATADRIVES="`cat /proc/partitions | grep "sd[a-z]$" | tr -s " " | cut -f 5 -d " " | tr "\n" " "`"

[ ! -d /proc/acpi ] && modprobe apm #v406

status_func 0

######################LOAD SWAP#####################
#load a swap partition...
for ONESWAP in `fdisk -l | grep ' Linux swap' | cut -f 1 -d ' ' | tr '\n' ' '`
do
 echo -n "Loading swap partition $ONESWAP..." >/dev/console
 swapon $ONESWAP
 status_func $?
done

#################MISC. SYSTEM SETUP#################
#100126 moved to /etc/init.d/00sys_logger...
#syslogd -m 0
#klogd
KERNVER="`uname -r`"

echo -e "${DISTRO_NAME} Linux\n`uname -s` `uname -r` [`uname -m` arch]\n\n" > /etc/issue
echo "1" > /proc/sys/net/ipv4/ip_dynaddr
hostname -F /etc/hostname

################WAIT MODULES LOADED##################
#previous module loading may not have completed...
echo -n "Waiting for modules to complete loading..." >/dev/console
WAITCNT=0
PCIPCMCIA="`elspci -l | grep -o '060700'`"
PCIUSB="`elspci -l | grep -o -E '0C0300|0C0310|0C0320'`"
if [ "$PCIPCMCIA" != "" ];then #this may be slow to respond.
 echo -n " pcmcia"  >/dev/console
 while [ $WAITCNT -lt 10 ];do
  [ "`lsmod | grep -E '^yenta_socket |^tcic |^i82092 |^i82365 |^pd6729 '`" != "" ] && break
  WAITCNT=`expr $WAITCNT + 1`
  sleep 1
  echo -n " $WAITCNT" >/dev/console
 done
fi
if [ "$PCIUSB" != "" ];then #this may be slow to respond.
 echo -n " usb"  >/dev/console
 PCIUSBNUM=`echo "$PCIUSB" | sort -u | wc -l`
 while [ $WAITCNT -lt 10 ];do
  [ `lsmod | grep -o -E '^uhci_hcd|^ohci_hcd|^ehci_hcd' | wc -l` -ge $PCIUSBNUM ] && break
  WAITCNT=`expr $WAITCNT + 1`
  sleep 1
  echo -n " $WAITCNT" >/dev/console
 done
fi

#replay uevents from /sys (more interfaces as a consequence of above drivers loaded)...
#note, this also a workaround for kernel 'bug' where entries appear in /sys but no uevent
#gets generated (yes it happens in 2.6.25.x kernel!)
[ -e /sys/bus/pcmcia/devices ] && NEWPCMCIA="`ls /sys/bus/pcmcia/devices/*/modalias | tr '\n' ' '`"
[ -e /sys/bus/usb/devices ] && NEWUSB="`ls /sys/bus/usb/devices/*/modalias | tr '\n' ' '`"
for ONEMODALIAS in ${NEWPCMCIA}${NEWUSB}
do
 ONEPATH="`dirname $ONEMODALIAS`"
 if [ -e ${ONEPATH}/uevent ];then
  echo add > ${ONEPATH}/uevent #generates an 'add' uevent.
  sleep 0.02
 fi
done
#wait for usb-storage drives to become available...
#note, pup_event_backend_d and udevd both log to this file when load modules
# (the latter via udev handler script /sbin/pup_event_backend_modprobe)...
if [ "`grep 'usb_storage' /tmp/pup_event_module_devpath_log`" != "" ];then #see pup_event_backend_d
 echo -n " usb-storage"  >/dev/console
 while [ $WAITCNT -lt 15 ];do
  [ "`dmesg | grep 'usb-storage: device scan complete'`" != "" ] && break
  sleep 1
  WAITCNT=`expr $WAITCNT + 1`
  echo -n " $WAITCNT" >/dev/console
 done
 #precaution, make sure have got them all...
 USBSTORAGES=`/bin/dmesg | grep "usb-storage: device found at" | wc -l`
 while [ $WAITCNT -lt 15 ];do
  AVAILABLEUSBSTORAGES=`/bin/dmesg | grep "usb-storage: device scan complete" | wc -l`
  [ $AVAILABLEUSBSTORAGES -ge $USBSTORAGES ] && break
  sleep 1
  WAITCNT=`expr $WAITCNT + 1`
  echo -n " $WAITCNT" >/dev/console
 done
fi

sleep 1 #v411 a bit extra. rerwin reports usb mouse detection problem some hardware.
        #(delay before usb mouse info appears in /proc/bus/input/devices)

status_func 0

################FIND PUPPY FILES################
echo -n "Looking for ${DISTRO_NAME} files in PC..." >/dev/console
PUPMODE=16
[ -f /${DISTRO_FILE_PREFIX}u${DISTRO_VERSION}.sfs ] && USRSFS="rootfs,rootfs,/${DISTRO_FILE_PREFIX}u${DISTRO_VERSION}.sfs"

#note, i think this is sorted so sr* drives list last (needed here)...
PROBEPART="`probepart -m | grep -E 'vfat|ntfs|ext2|ext3|reiserfs|minix|ext4|xfs|iso9660'`" #v411
for ONEFOUND in $PROBEPART
do
 ONEPART="`echo -n "$ONEFOUND" | cut -f 1 -d '|' | cut -f 3 -d '/'`"
 ONEFS="`echo -n "$ONEFOUND" | cut -f 2 -d '|'`"
 [ "$ONEFS" = "iso9660" -a "$USRSFS" != "" ] && continue #probe optical last resort.
 mkdir -p /mnt/$ONEPART
 mount -t $ONEFS /dev/$ONEPART /mnt/$ONEPART
 if [ $? -ne 0 ];then #for slow usb optical drives...
  sleep 5
  mount -t $ONEFS /dev/$ONEPART /mnt/$ONEPART
 fi
 if [ $? -eq 0 ];then
  [ -f /mnt/$ONEPART/${DISTRO_FILE_PREFIX}save.tar.gz ] && PUPSAVE="${ONEPART},${ONEFS},/${DISTRO_FILE_PREFIX}save.tar.gz"
  if [ -f /mnt/$ONEPART/${DISTRO_FILE_PREFIX}u${DISTRO_VERSION}.sfs ];then
   USRSFS="${ONEPART},${ONEFS},/${DISTRO_FILE_PREFIX}u${DISTRO_VERSION}.sfs"
   continue #do not unmount.
  fi
  umount /mnt/$ONEPART
 fi
done

[ "$USRSFS" = "" ] && STATUS=1

[ "$PNOSFS" = "yes" ] && USRSFS="" #v411
[ "$PNOSAVE" = "yes" ] && PUPSAVE="" #v411

#/${DISTRO_FILE_PREFIX}u<puppyversion>.sfs is the complete /usr directory compressed. mount as a layerfs...
if [ "$USRSFS" ];then
 USRMNTPT=""
 USRPART="`echo -n "$USRSFS" | cut -f 1 -d ','`"
 USRFS="`echo -n "$USRSFS" | cut -f 2 -d ','`"
 USRNAME="`echo -n "$USRSFS" | cut -f 3 -d ','`"
 [ "$USRPART" != "rootfs" ] && USRMNTPT="/mnt/$USRPART"
 if [ -f ${USRMNTPT}/initrd.gz -a -f ${USRMNTPT}/vmlinuz ];then
  PDEV1="$USRPART"
  DEV1FS="$USRFS"
 fi
 mkdir -p /.mnt/usr
 mkdir /.mnt/tmpfs1
 busybox losetup /dev/loop0 ${USRMNTPT}${USRNAME} #/${DISTRO_FILE_PREFIX}u${DISTRO_VERSION}.sfs
 busybox mount -r -t squashfs -o noatime /dev/loop0 /.mnt/usr
 busybox mount -t tmpfs tmpfs /.mnt/tmpfs1 #default size is "half of memory".
 if [ "$LAYERFS" = "aufs" ];then
  busybox mount -t aufs -o udba=reval,diropq=w,dirs=/.mnt/tmpfs1=rw:/.mnt/usr=ro unionfs /usr
 else #unionfs
  busybox mount -t unionfs -o dirs=/.mnt/tmpfs1=rw:/.mnt/usr=ro unionfs /usr
 fi
 STATUS=$?
 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R7/bin
fi

if [ "$PUPSAVE" ];then
 SAVEPART="`echo -n "$PUPSAVE" | cut -f 1 -d ','`"
 SAVEFS="`echo -n "$PUPSAVE" | cut -f 2 -d ','`"
 SAVENAME="`echo -n "$PUPSAVE" | cut -f 3 -d ','`"
 aPATTERN="/dev/${SAVEPART} "
 if [ "`mount | grep "$aPATTERN"`" = "" ];then
  MNTFLAG="yes"
  mount -t $SAVEFS /dev/$SAVEPART /mnt/$SAVEPART
  STATUS=$((STATUS+$?))
 fi
 if [ $STATUS -eq 0 ];then
  if [ -f /mnt/${SAVEPART}${SAVENAME} ];then
   echo -n " loading" >/dev/console
   #this reads the save file...
   tar -x -z -f /mnt/${SAVEPART}${SAVENAME} -C /
   sync
   if [ -f /mnt/${SAVEPART}initrd.gz -a -f /mnt/${SAVEPART}vmlinuz -a "${PDEV1}" = "" ];then
    PDEV1="$SAVEPART"
    DEV1FS="$SAVEFS"
   fi
   PUPMODE=24 #16+8
  fi
 fi
 [ "$MNTFLAG" ] && umount /dev/$SAVEPART
fi

echo "PUPMODE=$PUPMODE
PDEV1='${PDEV1}'
DEV1FS='${DEV1FS}'
PUPSAVE='${PUPSAVE}'
USRSFS='${USRSFS}'" > /etc/rc.d/PUPSTATE
if [ -e /proc/ide ];then
 echo "SATADRIVES='${ATADRIVES}'" >> /etc/rc.d/PUPSTATE #kernel supports /dev/hd*.
else
 echo "ATADRIVES='${ATADRIVES}'" >> /etc/rc.d/PUPSTATE
fi
ln -sf / /mnt/home

status_func $STATUS

##############USER SELECTED MODULES##################
#the user can select extra modules to load in the BootManager...
if [ "$ADDLIST" != "" ];then #variable is in /etc/rc.d/MODULESCONFIG
 echo -n "Loading user-selected modules..." >/dev/console
 for MODULE in $ADDLIST
 do
  MPARAMS=""
  if [ `echo -n "$MODULE" | tr ':' ' ' | wc -w` -gt 1 ];then
   MPARAMS="`echo -n "$MODULE" | cut -f 2-9 -d ':' | tr ':' ' '`"
   MODULE="`echo -n "$MODULE" | cut -f 1 -d ':'`"
  fi
  echo -n " $MODULE" >/dev/console
  echo "Loading module $MODULE $MPARAMS"
  firmware_module_func #install firmware tarball. see functions4puppy4.
  modprobe $MODULE $MPARAMS
 done
 status_func 0
fi

[ "$PNOSFS" = "yes" ] && exec /bin/sh >/dev/console 2>&1 #v411 drop out.

###################SETUP SERVICES################
echo -n "Setting up services (network, printing, etc.)..." >/dev/console
if [ -e /dev/modem ];then
 setserial -v -b /dev/modem auto_irq skip_test autoconfig
 check_status 0
fi

#had hoped to retire this, but HardInfo needs it...
[ "`lsmod | grep '^usbcore'`" != "" ] && busybox mount -t usbfs none /proc/bus/usb

#v411 can use old network wizard (from 403, based on 400)...
CHECKOLDWIZ="`ls -1 /etc/*[0-9]mode 2>/dev/null`" #ex: eth0mode, wlan0mode.
if [ "$CHECKOLDWIZ" != "" -a -d /usr/local/net_setup ];then
 #note, old wizard is located in /usr/local/net_setup.
 /usr/local/net_setup/etc/rc.d/rc.network &
else
 /etc/rc.d/rc.network &
fi

/etc/rc.d/rc.services & #run scripts in /etc/rc.d/init.d

echo -e "\\033[62G\\033[1;33m[backgrounded]\\033[0;39m" >/dev/console #column 62, yellow.

############RECOGNISE MEDIA DEVICES################
echo -n "Recognising media devices..." >/dev/console
#recognise optical drives...
echo -n ' optical' >/dev/console
OPTCNT=1;CDTYPE="";DVDTYPE="";CDBURNERTYPE=""
OPTICALS="`grep '^drive name:' /proc/sys/dev/cdrom/info | grep -o -E 'sr.*|hd.*' | tr '\t' ' '`"
[ -L /dev/cdrom ] && CDTYPE="`readlink /dev/cdrom | cut -f 3 -d '/'`"
[ -L /dev/dvd ] && DVDTYPE="`readlink /dev/dvd | cut -f 3 -d '/'`"
[ -f /etc/cdburnerdevice ] && CDBURNERTYPE="`cat /etc/cdburnerdevice`"
[ "`echo "$OPTICALS" | grep "$CDTYPE"`" = "" ] && CDTYPE="" #no longer exists.
[ "`echo "$OPTICALS" | grep "$DVDTYPE"`" = "" ] && DVDTYPE="" #no longer exists.
[ "`echo "$OPTICALS" | grep "$CDBURNERTYPE"`" = "" ] && CDBURNERTYPE="" #no longer exists.
for ONEOPTICAL in $OPTICALS
do
 ONENUM="`echo -n "$ONEOPTICAL" | cut -c 3`"
 [ "$CDTYPE" = "" ] && CDTYPE="$ONEOPTICAL"
 [ "$DVDTYPE" = "" ] && [ "`grep '^Can read DVD' /proc/sys/dev/cdrom/info | head -n 1 | grep -o '[01].*' | sed -e 's/[^01]//g' | cut -c $OPTCNT`" = "1" ] && DVDTYPE="$ONEOPTICAL" #100131
 [ "$CDBURNERTYPE" = "" ] && [ "`grep '^Can write CD' /proc/sys/dev/cdrom/info | head -n 1 | grep -o '[01].*' | sed -e 's/[^01]//g' | cut -c $OPTCNT`" = "1" ] && CDBURNERTYPE="$ONEOPTICAL" #100131
 OPTCNT=`expr $OPTCNT + 1`
done
rm -f /dev/cdrom; rm -f /dev/dvd; rm -f /etc/cdburnerdevice
[ "$CDTYPE" ] && ln -sf /dev/$CDTYPE /dev/cdrom
[ "$DVDTYPE" ] && ln -sf /dev/$DVDTYPE /dev/dvd
[ "$CDBURNERTYPE" ] && echo -n "$CDBURNERTYPE" > /etc/cdburnerdevice
[ "$DVDTYPE" ] && hdparm -d1 /dev/$DVDTYPE >/dev/null 2>&1

#recognise mouse... v411...
#note, if wanted to detect serial mouse here, k2.6.25.16 has module 'sermouse' that must be loaded (currently in xwin).
echo -n ' mouse' >/dev/console
if [ ! -f /etc/mousedevice_sticky ];then #see functions4puppy4.
 PS2MOUSEDEV="";USBMOUSEDEV="";SERMOUSEDEV="";MOUSEDEV="nothing"
 [ -f /etc/mousedevice ] && MOUSEDEV="`cat /etc/mousedevice`"
 #v411 return of puppyserialdetect for usb/ps2 mouse detection only...
 PUPPYINPUTDETECT="`/sbin/puppyinputdetect -mup`" #same thing from Jesse, but has no serial code.
 [ "$PUPPYINPUTDETECT" = "" ] && sleep 1 && PUPPYINPUTDETECT="`/sbin/puppyinputdetect -mup`" #rerwin: retry after delay.
 # ...v411 note, i also put in a permanent 'sleep 1' further up.
 [ "`echo "$PUPPYINPUTDETECT" | grep 'Type:USB-mouse'`" != "" ] && USBMOUSEDEV="input/mice"
 [ "`echo "$PUPPYINPUTDETECT" | grep 'Type:PS2-mouse'`" != "" ] && PS2MOUSEDEV="psaux"
 [ "`echo "$MOUSEDEV" | grep '^tty'`" != "" ] && SERMOUSEDEV="$MOUSEDEV" #fallback or manual choice.
 MOUSECHOICES="${USBMOUSEDEV}|${SERMOUSEDEV}|${PS2MOUSEDEV}"
 if [ "`echo -n "$MOUSECHOICES" | grep "$MOUSEDEV"`" = "" ];then
  #MOUSEDEV is not one of the existing choices, so must choose an existing mouse...
  NEWMOUSEDEV="`echo -n "$MOUSECHOICES" | cut -f 1 -d '|'`"
  [ "$NEWMOUSEDEV" = "" ] && NEWMOUSEDEV="`echo -n "$MOUSECHOICES" | cut -f 2 -d '|'`"
  [ "$NEWMOUSEDEV" = "" ] && NEWMOUSEDEV="`echo -n "$MOUSECHOICES" | cut -f 3 -d '|'`"
  #as we don't probe for a serial mouse, if no usb or ps2 mouse, fallback to assuming there must be a serial mouse...
  [ "$NEWMOUSEDEV" = "" ] && NEWMOUSEDEV="ttyS0"
  echo -n "$NEWMOUSEDEV" > /etc/mousedevice
  echo -n "$MOUSEDEV" > /etc/oldmousedevice
  ln -snf $NEWMOUSEDEV /dev/mouse
  choosemousefunc > /dev/console #see functions4puppy4.
 fi
fi
#TODO: simplify above, use 'input/mice' for ps2 mouse also, but may need to modify Xorg/Xvesa/Input Wizards.
#      (may also have to remove builtin psaux driver from kernel).

#recognise keyboard...
echo -n ' keyboard' >/dev/console
/etc/rc.d/rc.country #this asks for keyboard layout.

status_func 0


#personal boot script here...
if [ ! -f /etc/rc.d/rc.local ];then
 echo '#this file called from rc.sysinit' > /etc/rc.d/rc.local
 echo '#you can edit this file' >> /etc/rc.d/rc.local
 echo '#When firewall is installed, will append lines to this file...' >> /etc/rc.d/rc.local
fi
. /etc/rc.d/rc.local

#v411 PNOX is a boot param. /etc/profile prevents X from starting if this file exists...
[ "$PNOX" = "yes" ] && touch /tmp/bootcnt.txt

#that's it. next stop is /etc/profile...
###END###
